/* eslint-disable camelcase */
// 判断设备类型
const deviceType = (function () {
  var ua = window.navigator.userAgent.toLocaleLowerCase()
  var isIOS = /iphone|ipad|ipod/.test(ua)
  var isAndroid = /android/.test(ua)
  var isMiuiBrowser = /miuibrowser/.test(ua)
  var isPC = !isIOS && !isAndroid
  var isWx = /micromessenger/.test(ua)
  var isUCBrowser = /ucbrowser/.test(ua)
  var isQQBrowser = /mqqbrowser/.test(ua)
  var isHUAWEICOL_AL10 = /huaweicol-al10/.test(ua)
  var isAndroid_BAIDU =
    isAndroid && (/baiduboxapp/.test(ua) || /baidubrowser/.test(ua))
  var isOppoBrowser = /oppobrowser/.test(ua)

  var u = navigator.userAgent
  var isJXEDT = u.indexOf('JXEDT') > -1

  var isIphneX = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)

  if (isIphneX) {
    if (screen.height === 812 && screen.width === 375) {
      // 是iphoneX
    }
  }

  return {
    isOppoBrowser: isOppoBrowser,
    isJXEDT: isJXEDT,
    isIOS: isIOS,
    isAndroid: isAndroid,
    isMiuiBrowser: isMiuiBrowser,
    isPC: isPC,
    isWx: isWx,
    isSYSPlayer:
      isUCBrowser || isQQBrowser || isHUAWEICOL_AL10 || isAndroid_BAIDU
  }
})()
export default deviceType
